﻿using Finbuckle.MultiTenant.EntityFrameworkCore.Stores.EFCoreStore;
using Finbuckle.MultiTenant.Stores.Models;
using Microsoft.EntityFrameworkCore;

namespace MultiTenant.Api.Data;

public class TenantInfoStoreDbContext(DbContextOptions<TenantInfoStoreDbContext> options)
    : EFCoreStoreDbContext<AppTenantInfo>(options)
{
    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
        
        // Add multi-tenant configuration to Product entity
        builder.Entity<Product>().ToTable("Products");
        builder.Entity<Product>().Property(p => p.Id).ValueGeneratedOnAdd();
        builder.Entity<Product>().Property(p => p.Name).HasMaxLength(100).IsRequired();
    }
}